package com.huanzhidadi.springsecurity.util;

import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 把认证异常和鉴权异常的信息通过json格式返回前端
 */
@Slf4j
public class WebUtils {

    public static String renderString(HttpServletResponse response, String string) {
        try {
            response.setStatus(200);
            response.setContentType("application/json");
            response.setCharacterEncoding("utf-8");
            response.getWriter().print(string);
        } catch (IOException e) {
            log.error("renderString异常 ", e);
        }
        return null;
    }
}
